package cn.itcast.tools.java多线程;

class MyThread07 implements Runnable{ // 实现Runnable接口
    public void run(){  // 覆写run()方法
//        while(true){
            //System.out.println(Thread.currentThread().getName() + "在运行。") ;
            System.out.println("=========1========");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("=========2========");
//        }
    }
};

public class ThreadDaemonDemo07{


    public static void test(){
        MyThread07 mt = new MyThread07() ;  // 实例化Runnable子类对象
        Thread t = new Thread(mt,"线程");     // 实例化Thread对象
        t.setDaemon(true) ; // 此线程在后台运行
        t.start() ; // 启动线程
    }

    public static void main(String args[]){
        test();
        System.out.println("test函数调用结束");
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("主线程结束");
    }
};